package com.meevle.commands {
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.meevle.business.RecorderDelegate;
	import com.meevle.error.ErrorHandler;
	import com.meevle.events.StartRecordEvent;
	import com.meevle.model.StudioModelLocator;
	import com.meevle.model.ViewModelLocator;
	import com.meevle.vo.UserVO;
	
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	
	public class StartRecordCommand implements ICommand, IResponder {
		
		public function StartRecordCommand() {
			
		}
		
		// ICommand interface method
		public function execute(event:CairngormEvent):void {
			var startRecordEvent:StartRecordEvent = event as StartRecordEvent;

			var delegate:RecorderDelegate = new RecorderDelegate(this);
			delegate.startRecord(startRecordEvent.user, startRecordEvent.m_set, startRecordEvent.slot);
			
		}
		
		//IResponder interface methods
		public function result(event:Object) : void {
				StudioModelLocator.getInstance().isRecording = true;
				ViewModelLocator.getInstance().error = null;
		}
		
		public function fault(event:Object) : void {
			ErrorHandler.getInstance().handleError(event as FaultEvent);
		}	
	}
}